1. Field of the Invention
This invention generally relates to a method for bi-directional motion compensation, and more particularly to a method for bi-directional motion compensation to reduce the number of the registers.
2. Description of Related Art
Motion compensation is the required function to decode the ISO MPEG video image. Its major principle is to use the pervious decoded frame as a reference and to capture a block from the pervious decoded frame based on the motion vector as a predictor. By adding the predictor and the predicting error, the pixels of the present frame can be obtained.
Referring to FIGS. 1, 2, and 3, FIG. 1 shows the uni-directional motion compensation by using the predictor captured from the forward reference; FIG. 2 shows the uni-directional motion compensation by using the predictor captured from the backward reference; FIG. 3 shows the bi-directional motion compensation by averaging the predictors captured from the backward reference and the forward reference. In FIG. 3, we assume that the predictor captured from the forward reference is pel_pred_forward[y][x] and the predictor captured from the backward reference is pel_pred_backward[y][x], and by using the Inverse Discrete Consine Transform (IDCT), the predicted error is f[y][x]. Hence, the pixel data d[y][x] of the present frame can be obtained according to the MPEG standard as follows:
1. Averaging the predictors captured from the backward reference and the forward reference.
for(y=0;y<8;y++){for(x=0;x<8;x++){pel_pred[y][x]=( pel_pred_forward[y][x]+pel_pred_backward[y][x])//2 . . . (1)}}
Wherein “//2” means that it was divided by 2 and then rounded to nearest integer. Half-integer values were rounded away from zero.
2. Adding the average and the predicted error, and limiting the range of the pixel data to obtain the pixel data of the present frame. Because the length of the pixel data is 8 bits, the data ranges from 0-255.
for(y=0;y<8;y++){for(x=0;x<8;x++){d[y][x]=pel_pred[y][x] +f[y][x]  ; . . . (2)if(d[y][x]<0) d[y][x]=0 ;if(d[y][x]>255) d[y][x]255 ;}}
The above calculation steps will be performed by the hardware as shown in FIG. 4. In FIG. 4, it requires the IDCT register 410 to store the predicted error f[y][x] and the predictor register 420 to store the predictor pel_pred_forward[y][x] captured from the forward reference or the predictor pel_pred_backward[y][x] captured from the backward reference in order to perform bi-directional motion compensation.
In FIG. 4, as shown in the above formulae, the predictor pel_pred_forward [y][x] is obtained from the memory interface 430 and then stored in the predictor register 420. Then the predictor pel_pred_backward[y][x] is obtained from the memory interface 430. Then the operation of averaging the predictor pel_pred_forward [y][x] and the predictor pel_pred_backward[y][x] is performed. The average result and the predicted error f[y][x] in IDCT register 410 are added up. The added result passes through the limit operator 450 so that the pixel data d[y][x] can be limited between 0 and 255.
Because during the calculation, the memory interface 430 sends the predictor pel_pred_forward [y][x] to the predictor register 420 and the predictor pel_pred_backward[y][x] is obtained from the memory interface 430, if the predictor register 420 only has the size to store one predictor, i.e., only has 8 bits, it is required to alternately capture the predictor pel_pred_forward [y][x] and the predictor pel_pred_backward[y][x], which significantly affect the access efficiency of the DRAM. Hence, the conventional art generally increase the size of the predictor register 420 in order to capture several predictor data at a time to enhance the access efficiency of the DRAM. However, this conventional art will also increase the hardware cost.